package com.doublefish.doublefishrobot.ui.home.path.tools;

import com.doublefish.doublefishrobot.ui.home.path.bean.VelocityBean;

/**
 * 作者:dugaofeng on 2025/4/9 16:02
 */
public class PingPongTools {

    public static boolean isZero(float num) {
        if (num > -0.0000001 && num < 0.0000001) {
            return true;
        }
        return false;
    }

    public static float angleToRadian(float angle) {
        return (float) (angle * Math.PI / 180);
    }


    /// 将初始速度分解到xyz三个方向
    /// - Parameters:
    ///   - speed: 初始速度
    ///   - elevation: 仰角 上正 下负
    ///   - landpoint: 左右落点  右正 左负
    public static VelocityBean generateVelocityBean(float speed, float elevation, float landpoint) {
        VelocityBean bean = new VelocityBean();
        bean.setVx((float) (Math.sin(landpoint) * Math.cos(elevation) * speed));
        bean.setVy((float) (Math.cos(landpoint) * Math.cos(elevation) * speed));
        bean.setVz((float) (Math.sin(elevation) * speed));

        return bean;
    }
}
